<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;


/**
 * rank 最有钱的20个人
 */
class Rank extends Base
{
    public function logic()
    {
        $row = DB::table('t_player_info')
            ->where('robot_flag',0)
            ->where('status',1)
            ->orderBy('gold','desc')
            ->limit(20)
            ->get(['id','nick_name','avater_url','gold'])
            ->map(function ($value){
                return (array)$value;
            });
        $data = array();
        for ($i = 0; $i < count($row); $i++) {
            $arr               = array();
            $arr["uid"]        = (int)$row[$i]["id"];
            $arr["avater_url"] = (string)$row[$i]["avater_url"];
            $arr["gold"]       = (int)$row[$i]["gold"];
            $arr["nick_name"]  = $row[$i]["nick_name"];
            $data[]            = $arr;
        }
        return $this->returnData($data);
    }
}
